package com.mjk.common.web.getway.restful.interceptor.type.view.impl;



import com.mjk.common.base.response.BeeResponse;
import com.mjk.common.tools.interceptor.InterceptorChain;
import com.mjk.common.util.BeanUtils;
import com.mjk.common.web.getway.restful.interceptor.GetWayInterceptorReq;
import com.mjk.common.web.getway.restful.interceptor.annotation.BeeGetWayInterceptor;
import com.mjk.common.web.getway.restful.interceptor.type.GetWayInterceptor;
import com.mjk.common.web.getway.restful.interceptor.type.GetWayInterceptorType;

import java.util.HashMap;
import java.util.Map;

/**
 * 界面显示 拦截器
 * @author mjk
 *
 */
@BeeGetWayInterceptor(value=-999,interceptorType= GetWayInterceptorType.VIEW)
public class ViewInterceptor implements GetWayInterceptor {

	@Override
	public BeeResponse interceptor(GetWayInterceptorReq request,
								   InterceptorChain<GetWayInterceptorReq, BeeResponse> next) {
		Map<String, Object> params = new HashMap<>();
		params.putAll(request.getParams());
		params.putAll(request.getRestfulParams());
		return BeanUtils.toBean(request.getProtocal().invoke(params),BeeResponse.class);
	}

}
